﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>$CreationDate$</CreationDate>
</File>
*/
#endregion

using System;

namespace Outcoder.LauncherModel
{
	public class TaskAdapter
	{
		readonly Action<TaskAdapter> showAction;

		/// <summary>
		/// Initializes a new instance of the <see cref="TaskAdapter"/> class.
		/// </summary>
		/// <param name="showAction">The action to perform 
		/// when the Show method is called.</param>
		public TaskAdapter(Action<TaskAdapter> showAction = null)
		{
			this.showAction = showAction;
		}

		public void Show()
		{
			Shown = true;
			if (showAction != null)
			{
				showAction(this);
			}
		}

		public bool Shown { get; set; }
	}

	public class TaskAdapterBase<T> where T : TaskAdapterBase<T>
	{
		readonly Action<T> showAction;

		/// <summary>
		/// Initializes a new instance of the <see cref="TaskAdapter"/> class.
		/// </summary>
		/// <param name="showAction">The action to perform 
		/// when the Show method is called.</param>
		public TaskAdapterBase(Action<T> showAction = null)
		{
			this.showAction = showAction;
		}

		public void Show()
		{
			Shown = true;
			if (showAction != null)
			{
				showAction((T)this);
			}
		}

		public bool Shown { get; set; }
	}
}
